package bupt.xixi.learning.context.event;

import bupt.xixi.learning.beans.factory.BeanFactory;
import bupt.xixi.learning.context.ApplicationEvent;
import bupt.xixi.learning.context.ApplicationListener;

import java.util.Collection;

public class SimpleApplicationEventMulticaster extends AbstractApplicationEventMulticaster{

    public SimpleApplicationEventMulticaster(BeanFactory beanFactory) {
        setBeanFactory(beanFactory);
    }

    @Override
    public void multicastEvent(ApplicationEvent event) {
        Collection<ApplicationListener> listeners = getApplicationListener(event);
        for (ApplicationListener listener : listeners) {
            listener.onApplicationEvent(event);
        }
    }
}
